/**
 * Author:Sam
 * Description
 * Order records the food ordered and its related information
 * such as table number, time and number of customers.
 * 
 */
package GoldenEagle;

import java.util.ArrayList;
import java.util.Date;
import java.util.Scanner;

public class Order implements Displayable {
	private int numTable;
	private Date time = new Date();
	private ArrayList<MenuSubject> arrSubject;
	private String strStaffName;
	private int numCustomer;

	public Order(int intTable, int intCustomer, String staffName) {
		strStaffName = staffName;
		numTable = intTable;
		numCustomer = intCustomer;

		arrSubject = new ArrayList<MenuSubject>();
	}
	/**
	 * get MenuSubject(food/drink) from order
	 * @param index
	 * index of MenuSubject in order list
	 * @return
	 * MenuSubject of specified index
	 */
	public MenuSubject getMenuSubject(int index) {
		return arrSubject.get(index);
	}

	public int size() {
		return arrSubject.size();
	}

	public int getTable() {
		return numTable;
	}

	public int getNumOfCustomer() {
		return numCustomer;
	}

	public String getStaffName() {
		return strStaffName;
	}
	
	/**
	 * Calculator the total Price of the food
	 * and drink in the selected Order
	 * @return
	 * Total Price
	 */
	public float totalPrice() {
		float total = 0;
		MenuSubject food;
		for (int i = 0; i < arrSubject.size(); i++) {
			food = arrSubject.get(i);
			total += food.getPrice();
		}
		return total;
	}

	/**
	 * add the selected food or drink inside the arrSubject
	 * @param ms
	 * Food or Drink
	 */
	public void add(MenuSubject ms) {
		arrSubject.add(ms);
	}

	public static void displaySubMenu() {
		String info = "1. Add Order\n";
		info += "2. Change Order";

		System.out.println(info);
	}

	/**
	 * display all the information for the Order
	 */
	public void display() {

		System.out.println("Order Time: " + time.toString());
		System.out.print("Order by " + strStaffName);
		System.out.print("          Table: " + numTable + "\n");
		System.out.print("                      Customer: " + numCustomer
				+ " peopele\n");

		System.out.print("The Order Information:\n");

		for (int i = 0; i < arrSubject.size(); i++) {
			System.out.print(arrSubject.get(i) + "\n");
		}

	}
}
